package site.lisl.mynote.algorithm;

import site.lisl.mynote.algorithm.queue.ArrayQueue;
import site.lisl.mynote.algorithm.queue.CycleArrayQueue;
import site.lisl.mynote.algorithm.queue.LinkQueue;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) {
        System.out.println( "Hello World!" );
        int[][] abc = new int[][]{{1,2,3,4},{5,6,7,8}};
        System.out.println(abc[0][3]);
        System.out.println(abc[1][1]);

        testCycleArrayQueue();
    }


    private static void testCycleArrayQueue() {
        CycleArrayQueue arrayQueue = new CycleArrayQueue(3);
        System.out.println(arrayQueue.deQueue());

        arrayQueue.enQueue("A");
        arrayQueue.enQueue("B");
        arrayQueue.enQueue("C");
        System.out.println(arrayQueue.enQueue("D"));

        System.out.println("————————————————————————————————————————");

        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.enQueue("D"));

        System.out.println("————————————————————————————————————————");

        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
    }

    private static void testLinkQueue() {
        LinkQueue<String> linkQueue = new LinkQueue<>();

        linkQueue.enQueue("A");
        linkQueue.enQueue("B");
        linkQueue.enQueue("C");
        System.out.println(linkQueue.enQueue("G"));
        System.out.println(linkQueue.enQueue("D"));
        System.out.println(linkQueue.enQueue("E"));
        System.out.println(linkQueue.enQueue("F"));
        System.out.println(linkQueue.getSize());
        System.out.println("————————————————————————————————————————");

        System.out.println(linkQueue.deQueue());
        System.out.println(linkQueue.deQueue());
        System.out.println(linkQueue.deQueue());
        System.out.println(linkQueue.deQueue());
        System.out.println(linkQueue.getSize());
        System.out.println("————————————————————————————————————————");

        System.out.println(linkQueue.deQueue());
        System.out.println(linkQueue.deQueue());
        System.out.println(linkQueue.deQueue());
        System.out.println(linkQueue.deQueue());
    }

    private static void testArrayQueue() {
        ArrayQueue arrayQueue = new ArrayQueue(3);
        System.out.println(arrayQueue.deQueue());

        arrayQueue.enQueue("A");
        arrayQueue.enQueue("B");
        arrayQueue.enQueue("C");
        System.out.println(arrayQueue.enQueue("D"));

        System.out.println("————————————————————————————————————————");

        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.enQueue("D"));
        System.out.println(arrayQueue.enQueue("E"));
        System.out.println(arrayQueue.enQueue("F"));
        System.out.println("————————————————————————————————————————");

        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
        System.out.println(arrayQueue.deQueue());
    }
}
